
package com.eworking.eim.receive;

import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;

import com.eworking.eim.EIMManager;
import com.eworking.eim.user.EIMUserManager;

public class EIMRosterPresenceListener implements PacketListener {
    
    @Override
    public void processPacket(Packet packet) {
        if (packet instanceof Presence) {
            Presence presence = (Presence) packet;
            
            if (EIMManager.getInstance().isAppInited) {
                // 初始化已加载离线信息，直接处理即可
                EIMUserManager.getInstance().processOfflinePresences();
            } else {
                // 将离线消息添加到缓存中
                EIMUserManager.getInstance().addOfflinePresence(presence);
            }
        }
    }
}
